#ifndef _H_C_SERVICE_ADAPTER_HELPER_H_
#define _H_C_SERVICE_ADAPTER_HELPER_H_

#include "SServiceFrontendID.h"
#include "../SmartPtrDefine.h"
#include <atomic>
#include "../CPromiseMgrDefine.h"

namespace QWER
{
	QCLASS IServiceFrontend;
	QCLASS IRunner;
	QCLASS IService;
	QCLASS IToServiceBackendMsg;

	QDLL_EXPORT QCLASS CServiceFrontendHelper
	{
	public:
		CServiceFrontendHelper(PTR(IServiceFrontend) poServiceFrontend);
		inline PTR(IRunner) GetRunner() { return m_poRunner; }
		void PostMsgToBackend(QMOVEABLE(IToServiceBackendMsg) poMsg);

	private:
		SServiceFrontendID m_sFrontendID;
		IRunner* m_poRunner = NULL_PTR;
		IService* m_poService = NULL_PTR;

		static std::atomic<UINT64> s_qwFrontendID;

	private:
		friend class IRunner;
		template<typename T> friend class CNewBackendMsg;

		void _SetRunner(IRunner* poRunner);
		void _SetService(IService* poService);
	};
}

#endif
